export default {
	components: {

	},
	data() {
		return { 
			searchNavStatus: 4, 
			searchInputData: {
				companyKey: '',
				orderKey: '',
				fromArea: '临沂',
				toArea: ''
			},
			adObjData: {
				selectedTemplate: 'horizontal-sliding',
				imageClearance: 300,
				imageRadius: 8,
				marginTop: 8,
				list: [{
					title: "",
					description: "",
					image: "",
					url: ""
				}],
			},
			noticeObjData: {
				backgroundColor: '#fff',
				marginTop: 8,
				textColor: '#f39e00',
				fontSize: 16,
				style: 1,
				sources: 'diy',
				noticeIds: '1,2',
				list: [{
					link: {
						wap_url: '',
						appid: '',
						page: ''
					},
					content: '',
					createtime: '',
					id: '',
					name: '',
					nickname: '',
					title: '',
				}],
			},
			logisticsList: [{
				logo: '',
				logistics_name: '',
				address: '',
			}],
			background: ['color1', 'color2', 'color3'],
			indicatorDots: true,
			autoplay: true,
			interval: 2000,
			duration: 500,
			dynamicList: [],
			version_number:'',
		}
	},
	onPullDownRefresh() {
		uni.stopPullDownRefresh();
	},
	onReachBottom() {
		this.status = 'more';
	},
	onLoad(data) {
		this.getAdData();
		this.getLogisticsListData();
		this.getMessageDiscountData();
		this.getMemberDetail();
	},
	onShow() {

	},
	onBackPress() {
		// if (this.$refs.fab.isShow) {
		// 	this.$refs.fab.close()
		// 	return true
		// }
		return false
	},
	methods: {
		getScanShow() {
			var loginToken = uni.getStorageSync(this.preutils.loginToken);
			if (this.check.isNull(loginToken)) {
				// return false;
			}
			return true;
		},
		getMemberDetail() {
			var loginToken = uni.getStorageSync(this.preutils.loginToken);
			var openid = uni.getStorageSync('openid');
			if (!this.check.isNull(loginToken)) {
				openid = '';
			}
			var userinfo = uni.getStorageSync(this.preutils.userinfo)
			var data = {
				mid: userinfo.id
			};
			this.http.sendRequest({
				api: this.api.login.memberInfo,
				data: data,
				success: res => {
					if (res.code == 1) {
						getApp().globalData.userInfo = this.userInfo;
						uni.setStorageSync(this.preutils.accountLevel, res.data.site_level);
					} else {
						// this.$message(res.msg, "error");
					}
					if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
				},
				fail: res => {
					if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
				}
			});
		},
		getImgUrl(imgStr, type) {
			return this.$util.getImageUrl(imgStr, type);
		},
		showDepartTitle() {
			let level = uni.getStorageSync(this.preutils.accountLevel);
			if (level == 2) {
				return '发货凭证';
			} else if (level == 1) {
				return '发货凭证';
			} else if (level == 0) {
				return '分拨凭证';
			} else {
				return '发货凭证';
			}
		},
		showDepartListTitle() {
			let level = uni.getStorageSync(this.preutils.accountLevel);
			if (level == 2) {
				return '发货列表';
			} else if (level == 1) {
				return '发货列表';
			} else if (level == 0) {
				return '分拨列表';
			} else {
				return '发货列表';
			}
		},
		recommendClick(e) {
			this.toLogin();
			if (e == 1 || e == 2) {
				//1发货或分拨 2到站
				 // 允许从相机和相册扫码
				 var that = this;
				 uni.scanCode({
					 //是否只能从相机扫码,不能从相册扫码
					 onlyFromCamera: false,
					 //规定扫码类型  字节跳动小程序不支持此参数
					 // barcode就是一维码(条形码)  qrcode就是(er)维码 
					 // datamatrix就是Data Matrix码   pdf417就是PDF417条码
					 scanType: ['barCode', 'qrCode', 'datamatrix', 'pdf417'],
					 // 是否启动自动识别字符编码功能
					 autoDecodeCharset: false,
					 // 是否开启自动放大功能  仅 App-Android (3.5.4+) 支持
					 autoZoom: false,
					 // 是否支持手动输入条形码  仅飞书小程序（V3.14.0）支持
					 barCodeInput: false,
					 success: (res) => {
					 	that.toRedirect(e,res.result);
					 },
					 fail: (error) => {
					 	console.log('扫码失败了')
					 }
				 });
			}else{
				this.toRedirect(e,'');
			} 
		}, 
		toRedirect(e, urlStr) {
			var waybill_id = this.$util.getQueryVariable('waybill_id',urlStr);
			if (e == 1) {
				//1发货或分拨 2到站  11扫码-发货或分拨 21扫码-到站
				this.$util.redirectTo('/pages/order/order-detail/order-detail', {
					waybill_id: waybill_id,
					in_type: '21',
				});
			} else if (e == 2) {
				this.$util.redirectTo('/pages/order/order-detail/order-detail', {
					waybill_id: waybill_id,
					in_type: '11',
				});
			} else if (e == 3) {
				// uni.navigateTo({
				// 	url: "/pages/mine/print/template/title/templateTitle1"
				// });
				let obj = {
					type:'other'
				}  
				this.$util.redirectTo('/pages/tabBar/delivery/delivery', obj, '', 'obj');
			} else if (e == 4) {
				this.$util.redirectTo('/pages/waybill/car-list/car-list');
			} else if (e == 5) {
				this.$util.redirectTo('/pages/waybill/waybill-list/waybill-list');
			}
		},
		searchNavClick(e) {
			this.searchNavStatus = e; 
		},

		searchBtnClick(e) {
			if (e == 1) {
				var data = {
					companyKey: this.searchInputData.companyKey
				}
				//公司
				this.$util.redirectTo('/pages/home/search/company-search/company-search', data);
			} else if (e == 2) {
				var data = {
					toArea: this.searchInputData.toArea,
					fromArea: this.searchInputData.fromArea,
				}
				//线路
				this.$util.redirectTo('/pages/home/search/line-search/line-search', data);
			} else if (e == 4) {
				this.toLogin();
				var data = {
					orderKey: this.searchInputData.orderKey
				}
				this.$util.redirectTo('/pages/home/search/order-search/order-search', data);
 
			}
		},  
		toLogin(){
			if (!this.check.isLogin()) {
				uni.navigateTo({
					url: "/pages/login/login/login"
				});
				return
			}
		},
		getAdData() {
			var data = [{
				thumb: ''
			}]
			this.adObjData.list = data;
			this.http.sendRequest({
				api: this.api.home.sAdListApi,
				data: {},
				success: res => {
					this.adObjData.list = res.data;
					// console.log(this.adObjData.list)
				},
				fail: err => {

				}
			});
		},

		getLogisticsListData() {
			this.http.sendRequest({
				api: this.api.home.logisticsListApi,
				data: {
					page: '1',
					page_size: '5'
				},
				success: res => {
					this.logisticsList = res.data.data;
					// console.log(this.logisticsList)
				},
				fail: err => {

				}
			});
		},

		getMessageDiscountData() {
			// var data = {
			// 	page: '1',
			// 	keyword: '',
			// 	limit: '10'
			// };
			// this.http.sendRequest({
			// 	api: this.api.home.messageDiscountApi,
			// 	data: data,
			// 	success: res => {
			// 		// console.log(res)
			// 		if (res.success == 'true' && res.data) {
			// 			this.noticeObjData.list = res.data.data;
			// 		}
			// 	}
			// });
		},
		/**
		 * 商家个人信息
		 */
		mineShipperInfoData() {

			// this.http.sendRequest({
			// 	api: this.api.login.memberInfo,
			// 	data: {},
			// 	success: res => {
			// 		if (res.success == 'true' && res.data) {
			// 			this.userInfo = res.data;
			// 			getApp().globalData.userInfo = this.userInfo;
			// 		}
			// 	}
			// });
		},
	}

}